﻿using System;
using System.Data;
using System.Collections.Generic;

namespace LDSP.BRL
{
    public partial class PageSizeSetting : BYFW.BOL.BaseEntity
    {
        public PageSizeSetting()
        {
            m_tableName = "t_pageSizeSetting";
            m_tblCacheManager.IsEnable = true;
        }

        protected int m_userId = 0;
        protected int m_count = 0;
        protected string m_page = string.Empty;

        /// <summary>
        /// 用户ID
        /// </summary>
        public int UserId
        {
            get { return m_userId; }
            set { m_userId = value; }
        }
        /// <summary>
        /// 次数
        /// </summary>
        public int Count
        {
            get { return m_count; }
            set { m_count = value; }
        }
        /// <summary>
        /// 页面名称
        /// </summary>
        public string Page
        {
            get { return m_page; }
            set { m_page = value; }
        }

        protected override void FillContainer()
        {
            base.FillContainer();
            m_container.Add("userId", m_userId);
            m_container.Add("count", m_count);
            m_container.Add("page", m_page);
        }

        public override bool GetProperties(System.Data.DataRow record)
        {
            if (!base.GetProperties(record))
            {
                return false;
            }
            m_userId = this.GetIntValue(record, "userId");
            m_count = this.GetIntValue(record, "count");
            m_page = this.GetStringValue(record, "page");
            return true;
        }

        public PageSizeSetting GetPageSizeByUserAndPage(int userId, string page)
        {
            PageSizeSetting pageSizeSetting = null;
            List<PageSizeSetting> pageSizeSettings = GetSpecialList<PageSizeSetting>(null, "where userId = " + userId + " and page = '" + page + "'");
            if (pageSizeSettings.Count > 0)
            {
                pageSizeSetting = pageSizeSettings[0];
            }

            return pageSizeSetting;
        }
    }
}